Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 37

Thread: Help with Weapon Swapping

  1. #21
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Oh, I just experimented with the 'listinventory' command of the player class. This prints the specified player's inventory in the console:
    Sor has entered the battle
    'Name' : 'Amount'
    'Springfield '03 Sniper' : '1'
    'Frag Grenade' : '1'
    'Colt 45' : '1'
    'pistol' : '14'
    'rifle' : '55'
    'smg' : '0'
    'mg' : '0'
    'grenade' : '2'
    'agrenade' : '0'
    Note that I'm holding 1 Springfield '03 sniper and 55 'rifle'. This 'rifle' is the ammo for all rifle-weapontype weapons.
    Thus if you do this:
    Code:
    <player> take "models/weapons/springfield.tik"
    <player> take rifle
    then my springfield as well as all my rifle ammo will be taken away ^^ I guess this solves the other problem regarding
    your mod. If you give a new rifle-type weapon, the player will have the correct 'dmstartammo'.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  2. #22
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Hi

    So how would i get around this resetting , or i cant , because i need it executed after spawn but then it all resets , is there a way to add their name or client number and store it in an array or something and be able to get the choice thing to work that way , similar to the weapon not allowed list i used

    like
    Code:
    if(local.player.id == level.player.swap[local.i])
    {
    But i wouldnt no how to get the players to give and take the names or Id numbers from the array

    And ill have to have a disconnect handler to remove ids from array of players when they leave , or add a check to see if the ids in the array are still playing etc

    Would that work or not?

    Oh and thankyou for the ammo part , i tried all different things like that but must of forgot to try that one

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  3. #23
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    You didn't forget anything, it was just pure coincidence that I figured that out. Documentation just says:
    take ( String item_name )
    Takes away the specified item from the sentient.
    I just noticed that other, similar, commands were documented to work on anything in the player inventory.
    I suspected they meant the inventory as a whole, including ammo, and I tried the listinventory command
    and noticed that ammo was kept seperate from weapons with keyname of the respective ammotype.
    So I just tried it and it worked... for once



    As for the other problem. Yes, that's a big one. Up until now, the only way to make values persist through
    restarts and mapchanges alike was by use of cvar. With reborn we can also write them to a physical file.

    The problem of both methods is that the stored data has to be parsed at each restart/mapchange.
    That being said, a cvar is more appealing since you don't have to confront yourself with the new
    filesystem commands and elaborate parsing algorithms.
    The disadvantage of using cvars is that their capacity is limited, in not just length (string size per cvar)
    but also size (number of new cvars one can make before breaching the limit and crashing the game) and
    scope (these cvars will not be written to config, they expire once the server shuts down).

    This problem will be hopefully solved for good once I release the scripting framework. It's a problem that's
    been bugging me for a long time. The framework will introduce SessionStorage (while the map stays the same)
    and LocalStorage (until the server is shutdown) systems that can save all primitive types.

    In the meantime, we'll stick with cvars. First you'll need a function that can split strings on a specific character.
    This should do:
    Code:
    Split local.string local.spacer:
        local.strSize = local.string.size
        
        local.word = 1;
        local.result[local.word] = "";
        for (local.i = 0; local.i < local.strSize; local.i++) {
            if (local.spacer == local.string[local.i]) {
                if !(local.string[(local.i + 1)] == local.spacer) {
                    if(local.result[local.word] != "") {
                        local.word++;
                        local.result[local.word] = "";
                    }
                }
                continue;
            }
            local.result[local.word] += local.string[local.i];
        }
    end local.result;
    The reason you need it, is because cvars can only store one string. This means your input
    has to be formatted into a single string in such a way that we can easily translate that
    string back into the original input later. This requires a 'compile' and a 'decompile' algorithm.

    We'll start with compiling. Your input is the .swap property associated with all players currently
    playing. The input will be your $player array but to differentiate between players we can't rely
    on the client id number since it may change during a mapchange.
    What doesn't change over a playing session on a server are their IP addresses. Too bad
    there's a possibility of multiple players with the same IP on your server. However, even though
    the player's name may change, we know it won't change during a mapchange (loading screen)
    or a restart (too fast).

    Now we have two values that allow us to pinpoint the same player no matter how many mapchanges or -restarts have occurred!
    Let's start by compiling these three values. First, we need 2 global variables:
    Code:
    main:
        level.valSep = ","    //seperator character to seperate the values
        level.entrSep = ";"    //seperator character to seperate (player) entries 
    end;
    Now for our compile thread:
    Code:
    Compile:
        local.cvarStr = "";
        for (local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            
            // Catches all NILs
            if (local.player.swap != "1") {
                local.player.swap = "0"
            }
            
            /// Compilation phase.. no need to cast to string :)
            // Add             player's name            value seperator        player's ip            value seperator        player's property        entry seperator
            local.cvarStr += ((netname local.player) + (level.valSep) + (getip local.player) + (level.valSep) + (local.player.swap) + (level.entrSep));
        }
        
        // Save compiled string to cvar
        setcvar "sessionSwapData" local.cvarStr;
    end;
    This should be run, ideally, during intermission. In other words right before a round or level ends.
    I haven't experimented with the intermission event much, I hope it detects round restarts as well.

    To present what I'm doing there more visually, I'm formatting a player's data like this:
    name,ip,swap
    eg:
    unnamedsoldier,127.0.0.1,1
    Each comma seperates each value. Values have fixed positions. Every such block is then terminated with a semicolon.
    With this I can quickly differentiate between values and a block of values belonging to one player.
    I guess this may cause problems if a player has a comma or a semicolon in his name... which is highly unusual but if it
    bothers you, try using more exotic characters like these two escape sequences:
    Code:
    main:
        level.valSep = "\t"    //seperator character to seperate the values
        level.entrSep = "\n"    //seperator character to seperate (player) entries 
    end;
    Both compile and decompile threads use these variables. So if there was a string saved from last round/level, we need to
    decompile it with this:
    Code:
    Decompile:
        // Break 'sessionSwapData' string into strings of the entries.
        level.sessionSwapData = waitthread Split (getcvar("sessionSwapData")) level.entrSep;
        // No longer needed;
        setcvar "sessionSwapData" "";
        
        // Array of strings isn't empty (this means the cvar "sessionSwapData" wasn't empty)
        if (0 < level.sessionSwapData.size) {
            // Save initial size (We're going to remove elements without reconcatenating  
            // the array later on to save time and resources).
            level.sessionSwapDataSize = level.sessionSwapData.size;
            
            // Split values as well and creat a two-dimensional array.
            for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
                // Now split entry string into its 3 value strings. In our compile phase,
                // each value had a fixed position. This is maintained. :)
                level.sessionSwapData[local.i] = waitthread Split level.sessionSwapData[local.i] level.valSep;
            }
        }
    end;
    This script should be run, ideally, right after level waittill spawn.

    Finally, register the connected event and make the connection script execute this thread:
    Code:
    GetSwapDataForClient local.player:
        local.result = 0;
        for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
            // Element is not inexistent and is an array which 
            // contains a valid amount of elements itself.
            if (level.sessionSwapData[local.i].size == 3) {
                if ((getip local.player) == local.sessionSwapData[local.i][2]) {
                    if ((netname local.player) == local.sessionSwapData[local.i][1]) {
                        // Player was found!
                        // He did not disconnect during mapchange...
                        local.player.swap = local.sessionSwapData[local.i][3];
                        
                        // No need to keep this set of data anymore (frees memory and
                        // makes this algorithm run faster next time).
                        local.sessionSwapData[local.i] = NIL;
                        
                        // exit
                        local.result = 1;
                        break;
                    }
                }
            }
        }
    end local.result;
    This will find the correct swap value, if any, for the player and this thread will also return 1 if a value was found
    and 0 if nothing was found.

    I haven't actually tested it yet. But this is the general approach to take.
    Last edited by Sor; February 10th, 2013 at 06:10 PM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  4. #24
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Ok

    I think i have it set up properly , everything still works , except the swapping again , doesnt remember it

    Ok i went through logs and found an error in the GetSwapDataForClient thread

    Code:
    Player2 has entered the battle
        for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) { (global/custom/weapons.scr, 83)
        for (local.i = 1; local.i ^
    
    ^~^~^ Script Error: binary '<=' applied to incompatible types 'int' and 'NIL'
    But i am using same IP to connect and maybe it doesnt like it aswell

    And another error in Split string thread

    Code:
         if !(local.string[(local.i + 1)] == local.spacer) { (global/custom/weapons.scr, 28)
                if !(local.string^
    
    ^~^~^ Script Error: String index '60' out of range
    This is what ive got

    Code:
    main:
    
    //local.result = registerev "spawn" global/custom/weapons.scr::spawn
    local.result = registerev "connected" global/custom/weapons.scr::connected
    local.result = registerev "intermission" global/custom/weapons.scr::intermission
    level.mef_pstatecallbacks.spawned = global/custom/weapons.scr::spawn
    
    level.valSep = "\t"    //seperator character to seperate the values
    level.entrSep = "\n"    //seperator character to seperate (player) entries 
    
    thread get_cvars
    
    thread weapon_message
    
    teamswitchdelay .2
    
    end
    
    ////////////////////////////////
    
    Split local.string local.spacer:
        local.strSize = local.string.size
        
        local.word = 1;
        local.result[local.word] = "";
        for (local.i = 0; local.i < local.strSize; local.i++) {
            if (local.spacer == local.string[local.i]) {
                if !(local.string[(local.i + 1)] == local.spacer) {
                    if(local.result[local.word] != "") {
                        local.word++;
                        local.result[local.word] = "";
                    }
                }
                continue;
            }
            local.result[local.word] += local.string[local.i];
        }
    end local.result;
    
    ///////////////////////
    intermission local.type:
    
    thread Compile
    
    
    end
    
    ////////////////////////////////
    
    
    
    Compile:
        local.cvarStr = "";
        for (local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            
            // Catches all NILs
            if (local.player.swap != "1") {
                local.player.swap = "0"
            }
            
            /// Compilation phase.. no need to cast to string :)
            // Add             player's name            value seperator        player's ip            value seperator        player's property        entry seperator
            local.cvarStr += ((netname local.player) + (level.valSep) + (getip local.player) + (level.valSep) + (local.player.swap) + (level.entrSep));
        }
        
        // Save compiled string to cvar
        setcvar "sessionSwapData" local.cvarStr;
    end;
    
    
    
    ////////////////////////////////
    
    connected local.player:
    
    thread GetSwapDataForClient local.player
    
    end
    ///////////////////////////////////////////////
    GetSwapDataForClient local.player:
        local.result = 0;
        for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
            // Element is not inexistent and is an array which 
            // contains a valid amount of elements itself.
            if (level.sessionSwapData[local.i].size == 3) {
                if ((getip local.player) == local.sessionSwapData[local.i][2]) {
                    if ((netname local.player) == local.sessionSwapData[local.i][1]) {
                        // Player was found!
                        // He did not disconnect during mapchange...
                        local.player.swap = local.sessionSwapData[local.i][3];
                        
                        // No need to keep this set of data anymore (frees memory and
                        // makes this algorithm run faster next time).
                        local.sessionSwapData[local.i] = NIL;
                        
                        // exit
                        local.result = 1;
                        break;
                    }
                }
            }
        }
    end local.result;
    
    //////////////////////////////
    
    spawn local.player:
    
    waitthread weapon_check local.player
    
    waitthread Decompile
    
    thread weapon_swap local.player
    
    end
    ///////////////////////////////////////////
    
    Decompile:
        // Break 'sessionSwapData' string into strings of the entries.
        level.sessionSwapData = waitthread Split (getcvar("sessionSwapData")) level.entrSep;
        // No longer needed;
        setcvar "sessionSwapData" "";
        
        // Array of strings isn't empty (this means the cvar "sessionSwapData" wasn't empty)
        if (0 < level.sessionSwapData.size) {
            // Save initial size (We're going to remove elements without reconcatenating  
            // the array later on to save time and resources).
            level.sessionSwapDataSize = level.sessionSwapData.size;
            
            // Split values as well and creat a two-dimensional array.
            for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
                // Now split entry string into its 3 value strings. In our compile phase,
                // each value had a fixed position. This is maintained. :)
                level.sessionSwapData[local.i] = waitthread Split level.sessionSwapData[local.i] level.valSep;
            }
        }
    end;
    
    
    ////////////////////////////////////////////////////////////
    ////////////// Weapon Check Part ///////////////////////////
    
    weapon_check local.player:
    
    wait 0.6
    
    if(local.player != NULL && local.player != NIL && isAlive(local.player) && local.player.dmteam != spectator && !local.player.checked)
    {
    
    local.player iprint "Start Check"
    
    		local.player weaponcommand dual targetname ("weap" + local.player.entnum )
    		local.player.weapon = $("weap" + local.player.entnum ).model
    		
    		if(local.player.weapon != NIL && local.player.weapon != NULL)
    		
    		{
    				for (local.i = 1; local.i <= level.notallowed.size; local.i++) 
    				{
    					   if(local.player.weapon == level.notallowed[local.i])
    						{	
    								local.player take level.notallowed[local.i]
    								local.player iprint "Not Allowed"
    														if(getcvar(pe_weapon_choice) != "1")
    														{ 
    														local.player give models/weapons/KAR98sniper.tik
    														local.player use models/weapons/KAR98sniper.tik
    														local.player primarydmweapon sniper
    														}
    														if(getcvar(pe_weapon_choice) == "1")
    														{
    														local.player spectator
    														local.player stufftext "pushmenu SelectPrimaryWeapon"
    														}
    								
    										if(getcvar(pe_weapon_message) == "1") 
    														{
    															local.player iprint ("The Weapon you chose is unavailable") 1
    															local.player iprint (level.allowed) 1
    															//local.player iprint ("So here is a Sniper") 1	
    														}
    								
    						}
    						local.player.checked = 1
    						
    									
    				}
    		}
    		
    
    
    
    local.player iprint "End Check"
    
    }
    
    wait 0.5
    local.player.checked = 0	
    end
    
    
    ////////////////////////////////////////////////////////////
    ////////////// Weapon Swap Part ///////////////////////////
    
    
    weapon_swap local.player:
    
        if (getcvar(pe_weapon_swap) == "1") 
        {
            if(local.player && isAlive(local.player) && local.player.dmteam == "allies")
    		
    	      {
                local.player iprint "Swap Start"
                local.player weaponcommand dual targetname ("weap" + local.player.entnum )
                local.player.weapon = $("weap" + local.player.entnum ).model
                
                switch(local.player.weapon)
                {
                    case "models/weapons/springfield.tik":
                        local.take = "models/weapons/springfield.tik"
                        local.takename = "Springfield"
                        local.give = "models/weapons/KAR98sniper.tik"
                        local.givename = "Kar98Sniper"
                    break
                     
                    case "models/weapons/m1_garand.tik":
                        local.take = "models/weapons/m1_garand.tik"
                        local.takename = " M1 Garand"
                        local.give = "models/weapons/kar98.tik"
                        local.givename = "Mausar kar98"
                    break
                    default:
                        end
                }
                
                wait 1    
            
                if(local.player && isAlive(local.player) && local.player.dmteam != "spectator")
                {
                    if(level.swap == "1")
                    {
                        local.player take local.take
    					local.player take rifle
                        local.player give local.give
                        local.player iprint (local.takename + " has been swapped for " + local.givename) 1
                        local.player use local.give
                        local.player iprint ("Hold 'Use' again to change back") 1
    
    
                        local.wait = 3.0
                        while(local.player.useheld && 0.0 < local.wait) {
                            wait 0.25
                            local.wait -= 0.25
                        }
                        
                        if (local.wait <= 0.0) {
                            local.player take local.give
    						local.player take rifle
                            local.player give local.take                    
                            local.player use local.take
                            level.swap = "0"
    						
                        }
    					 
                    } else {  
    				local.player iprint ("Hold 'Use' for 3 Seconds to change") 1
    					wait 1
                        local.wait = 2.0
                        while(local.player.useheld && 0.0 < local.wait) {
                            wait 0.25
                            local.wait -= 0.25
                        }
                        
                        if (local.wait <= 0.0) {
                            local.player take local.take
    						local.player take rifle
                            local.player give local.give
                            local.player iprint (local.takename + " has been swapped for " + local.givename) 1
                            local.player use local.give
                            level.swap = "1"
    						 
    						
                        }
                    }
    				 
    				local.player iprint "Swap End"
    				
    				  
                }
    			
            }
          
        }
     wait 0.5
    
    
    
    
    end
    
    get_cvars:
    
    //////////////////////////////
    level.notallowed[1] = ""
    level.notallowed[2] = ""
    level.notallowed[3] = ""
    level.notallowed[4] = ""
    level.notallowed[5] = ""
    level.notallowed[6] = ""
    level.notallowed[7] = ""
    level.notallowed[8] = ""
    level.notallowed[9] = ""
    level.notallowed[10] = ""
    level.notallowed[11] = ""
    //////////////////////////////////////////////////////////////
    //////////////////////  Get Cvars ////////////////////////////
    
    if(getcvar(PE_mg) == "0")
    		{
    			level.notallowed[1] = "models/weapons/bar.tik"
    			level.notallowed[2] = "models/weapons/mp44.tik"
    		}
    
    if(getcvar(PE_rocket) == "0")
    		{
    			level.notallowed[3] = "models/weapons/bazooka.tik"
    			level.notallowed[4] = "models/weapons/panzerschreck.tik"
    		}
    
    if(getcvar(PE_shotgun) == "0")
    		{
    			level.notallowed[5] = "models/weapons/shotgun.tik"
    		}
    
    if(getcvar(PE_rifle) == "0")
    		{
    			level.notallowed[6] = "models/weapons/m1_garand.tik"
    			level.notallowed[7] = "models/weapons/kar98.tik"
    		}
    
    if(getcvar(PE_sniper) == "0")
    		{
    			level.notallowed[8] = "models/weapons/springfield.tik"
    			level.notallowed[9] = "models/weapons/KAR98sniper.tik"
    		}
    
    if(getcvar(PE_smg) == "0")
    		{
    			level.notallowed[10] = "models/weapons/thompsonsmg.tik"
    			level.notallowed[11] = "models/weapons/mp40.tik"
    		}
    
    if(getcvar(PE_pistol) == "0")
    		{
    			level.player take "models/weapons/colt45.tik"
    			level.player take "models/weapons/p38.tik"
    		}
    
    if(getcvar(PE_grenade) == "0")
    		{
    			level.player take "models/weapons/m2frag_grenade.tik"
    			level.player take "models/weapons/steilhandgranate.tik"
    		}
    
    end
    /////////////////////////////////////////////////////////////
    /////////////////////// Message Part /////////////////////////
    
    weapon_message:
    
    level.allowed = "Allowed Weapons:"
        if (getcvar(pe_allweapons) == "1") 
            level.allowed += " All Weapons "
        else
        {
            if (getcvar(pe_pistol) == "1") 
                level.allowed += " Pistol,"
            if (getcvar(pe_rifle) == "1")
                level.allowed += " Rifle,"
            if (getcvar(pe_sniper) == "1") 
                level.allowed += " Sniper,"
            if (getcvar(pe_smg) == "1") 
                level.allowed += " SMG,"
            if (getcvar(pe_mg) == "1") 
                level.allowed += " MG,"
            if (getcvar(pe_grenade) == "1") 
                level.allowed += " Grenades,"
            if (getcvar(pe_shotgun) == "1") 
                level.allowed += " Shotgun,"
            if (getcvar(pe_rocket) == "1") 
                level.allowed += " Rocket,"
    
        }
    
    end

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  5. #25
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Yeah, made a mistake in my previous thread :P
    The Decompile thread needs to be right before level waittill spawn or right after (for the restarts). Not in the spawn event, as it only needs to be run once.
    When I'm back from college I'll take another look, because I quickly wrote those scripts last night.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  6. #26
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Yea i tried exec it from the main part , which is exec from dmprecache and still no luck

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  7. #27
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Did you wait until the server has restarted/changed maps after the first time this script is run? Use this get rid of the NIL error:
    Code:
    Decompile:
        // Break 'sessionSwapData' string into strings of the entries.
        level.sessionSwapData = waitthread Split (getcvar("sessionSwapData")) level.entrSep;
        // No longer needed;
        setcvar "sessionSwapData" "";
        
        // Array of strings isn't empty (this means the cvar "sessionSwapData" wasn't empty)
        if (0 < level.sessionSwapData.size) {
            // Split values as well and create a two-dimensional array.
            for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
                // Now split entry string into its 3 value strings. In our compile phase,
                // each value had a fixed position. This is maintained. :)
                level.sessionSwapData[local.i] = waitthread Split level.sessionSwapData[local.i] level.valSep;
            }
        }
        // Save initial size (We're going to remove elements without reconcatenating  
        // the array later on to save time and resources).
        level.sessionSwapDataSize = level.sessionSwapData.size;
    end;
    EDIT: As for the Split error:
    Code:
    Split local.string local.spacer:
        local.strSize = local.string.size;
        
        // HACK! Efficiently prevents console from producing an
        // 'out-of-range' error at the second spacer check.
        local.string += local.spacer;
        
        local.word = 1;
        local.result[local.word] = "";
        for (local.i = 0; local.i < local.strSize; local.i++) {
            if (local.spacer == local.string[local.i]) {
                if (local.string[(local.i + 1)] != local.spacer) {
                    if(local.result[local.word] != "") {
                        local.word++;
                        local.result[local.word] = "";
                    }
                }
                continue;
            }
            local.result[local.word] += local.string[local.i];
        }
    end local.result;
    EDIT2: I noticed that the Decompile thread is not called. You should call it right after level waittill spawn.
    Last edited by Sor; February 11th, 2013 at 04:25 PM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  8. #28
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Ok , I tried with the decompile thread called just after the level waittill spawn in the main part of the thread , that didnt work , then also exec it from dmprecache after the waittill spawn , changed maps after starting server , a few times , but still no luck

    Errors in logs

    This one in GetSwapDataForClient thread ,
    Code:
    Player2 has entered the battle
        for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) { (global/custom/weapons.scr, 91)
        for (local.i = 1; local.i ^
    
    ^~^~^ Script Error: binary '<=' applied to incompatible types 'int' and 'NIL'
    This one in Decompile , seems to be the same error just in decompile and get , so its either not decompiling right of saving right..
    Code:
    Cvar_Set2: sessionSwapData 
            for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) { (global/custom/weapons.scr, 134)
            for (local.i = 1; local.i ^
    
    ^~^~^ Script Error: binary '<=' applied to incompatible types 'int' and 'NIL'
    But since im testing this with the same PC , so they have same IP , thats probably why , different names but same IP

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  9. #29
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Oh, my mistake:
    Code:
    Decompile:
        // Break 'sessionSwapData' string into strings of the entries.
        level.sessionSwapData = waitthread Split (getcvar("sessionSwapData")) level.entrSep;
        // No longer needed;
        setcvar "sessionSwapData" "";
    	
        // Save initial size (We're going to remove elements without reconcatenating  
        // the array later on to save time and resources).
        level.sessionSwapDataSize = level.sessionSwapData.size;
        
        // Array of strings isn't empty (this means the cvar "sessionSwapData" wasn't empty)
        if (0 < level.sessionSwapDataSize) {
            // Split values as well and create a two-dimensional array.
            for (local.i = 1; local.i <= level.sessionSwapDataSize; local.i++) {
                // Now split entry string into its 3 value strings. In our compile phase,
                // each value had a fixed position. This is maintained. :)
                level.sessionSwapData[local.i] = waitthread Split level.sessionSwapData[local.i] level.valSep;
            }
        }
    end;
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  10. #30
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    This is getting annoying aye , lol

    The error from the GetSwapDataForClient thread persists , but its still not working , i think ill just have to make due with them choosing it each round,

    No other errors are there from the script , so thats always good , it might work on my actual server , im just testing locally so it might not like storing the same ip

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •